/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.dao;

import java.util.List;
import server.domain.Product;

/**
 *
 * @author fillipe
 */
public class ProductDAO extends GenericDAO<Product> {

    public ProductDAO() {
        super(Product.class);
    }

    public List<Product> getByDescription(String description) throws Exception {
        return list("from Product p where p.description like ?", description + "%");
    }

    public boolean existProductOrder(Long productId) {
        return !list("from OrderItem oi where oi.id.product.id = ?", productId).isEmpty();
    }
}
